<!doctype html>
<html lang="en">
<head>
	<title>Useful utilities and toys over DNS</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="description" content="Free and useful services over DNS accessible on command line" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />

	<link href="https://fonts.googleapis.com/css?family=Inter:400,600" rel="stylesheet" defer />
	<meta property="og:image" content="https://www.dns.toys/static/thumb.png">
		<link rel="shortcut icon" href="static/favicon.png" />
	<link rel="stylesheet" type="text/css" href="static/style.css" />
</head>
<body>

<div class="container">
	<header class="header">
		<div class="logo">
			<a href="/"><img src="static/logo.png" alt="DNS toys" /></a>
		</div>
		<nav class="nav">
			<a href="https://github.com/knadh/dns.toys">GitHub</a>
		</nav>
	</header>
	<section class="intro">
		<h1 class="center"><span>Useful utilities and services over DNS</span></h1>

		<p>
			dns.toys is a DNS server that takes creative liberties with the DNS
			protocol to offer handy utilities and services
			that are easily accessible via the command line.
			Copy and run the below commands to try it out.
		</p>
	</section>

	<section>
		<table class="box services">
			<thead>
				<tr>
					<th>Service</th>
					<th>Usage<span>(Click to copy)</span></th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td><span class="name">World time</span><br><span class="desc">Get current time for cities. Pass city names without spaces suffixed with .time. Optional two letter country codes.</span></td>
					<td><code>dig mumbai.time @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Timezone conversion</span><br><span class="desc">Convert time between cities using format YYYY-MM-DDTHH:MM-$fromCity-$toCity</span></td>
					<td><code>dig 2023-05-28T14:00-mumbai-paris/fr.time @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Weather</span><br><span class="desc">Get weather for cities. Pass city names without spaces. Optional country codes.</span></td>
					<td><code>dig mumbai.weather @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Unit conversion</span><br><span class="desc">Convert between 70+ different units</span></td>
					<td><code>dig 42km-mi.unit @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Currency conversion</span><br><span class="desc">Convert between currencies using daily rates</span></td>
					<td><code>dig 100USD-INR.fx @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">IP echo</span><br><span class="desc">Show your IPv4 or IPv6 address</span></td>
					<td><code>dig -4 ip @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Number to words</span><br><span class="desc">Convert numbers to English words</span></td>
					<td><code>dig 987654321.words @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">CIDR range</span><br><span class="desc">Find first and last usable IP in subnet</span></td>
					<td><code>dig 10.0.0.0/24.cidr @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Base conversion</span><br><span class="desc">Convert between number bases (hex, dec, oct, bin)</span></td>
					<td><code>dig 100dec-hex.base @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Pi</span><br><span class="desc">Print digits of Pi</span></td>
					<td><code>dig pi @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Dictionary</span><br><span class="desc">Get English word definitions (use dashes for spaces)</span></td>
					<td><code>dig fun.dict @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Dice roll</span><br><span class="desc">Roll dice with specified number and sides</span></td>
					<td><code>dig 3d20/2.dice @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Coin toss</span><br><span class="desc">Flip one or more coins</span></td>
					<td><code>dig 2.coin @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Random number generation</span><br><span class="desc">Generate random number in a given range</span></td>
					<td><code>dig 1-100.rand @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Epoch conversion</span><br><span class="desc">Convert Unix timestamp to readable date</span></td>
					<td><code>dig 784783800.epoch @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Aerial distance</span><br><span class="desc">Calculate distance between lat-long pairs</span></td>
					<td><code>dig 12.9352,77.6245/12.9698,77.7500.aerial @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">UUID generation</span><br><span class="desc">Generate UUIDs (v4)</span></td>
					<td><code>dig 5.uuid @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Sudoku solver</span><br><span class="desc">Solve Sudoku puzzles (use 0 for empty cells)</span></td>
					<td><code>dig 002840003...sudoku @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Developer excuses</span><br><span class="desc">Get a random developer excuse</span></td>
					<td><code>dig excuse @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">NanoID generation</span><br><span class="desc">Generate NanoIDs with specified length: $len.$num</span></td>
					<td><code>dig 5.10.nanoid @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">IFSC lookup</span><br><span class="desc">Get bank (India) details for IFSC code</span></td>
					<td><code>dig ABNA0000001.ifsc @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">Vitamin info</span><br><span class="desc">Get the common name, scientific name, and food sources for a vitamin</span></td>
					<td><code>dig a.vitamin @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">DIGIPIN</span><br /><span class="desc">Convert between lat, long and IndiaPost DIGPIN hash</span></td>
					<td><code>dig 23.241312,79.553617.digipin @dns.toys</code><br /><code>dig 36L-9K9-9J57.digipin @dns.toys</code></td>
				</tr>
				<tr>
					<td><span class="name">ISS location</span><br /><span class="desc">Track the location of the ISS (International Space Station)</span></td>
					<td>
						<code>dig iss.sky @dns.toys</code>
						<br />
						To open Google maps with the current location of the ISS:<br />
						<code><small>xdg-open $(dig iss.sky @dns.toys | grep -oP 'https://[^"]*')</small></code>
					</td>
				</tr>
			</tbody>
		</table>
	</section>

	<section>
		<h1>Shortcut functions</h1>
		<p>Add a shortcut command <code>dy</code> which can be used like <code>dy mumbai.weather</code></p>
		
		<table class="box">
			<thead>
				<tr>
					<th>Shell</th>
					<th>Description</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>Bash</td>
					<td>Add to ~/.bashrc <code>alias dy="dig +short @dns.toys"</code></td>
				</tr>
				<tr>
					<td>Fish</td>
					<td>Add to ~/.config/fish/config.fish <code>alias dy="dig +noall +answer +additional $argv @dns.toys"</code></td>
				</tr>
				<tr>
					<td>Zsh</td>
					<td>Add to ~/.zshrc <code>alias dy="dig +short @dns.toys"</code></td>
				</tr>
			</tbody>
		</table>
	</section>

	<section>
		<h1>Why?</h1>
		Why not? For fun. I spend a lot of time on the terminal and doing quick unit
		conversions, weather checks etc. without having to open a clunky search
		page is useful. 
	</section>
</div>

<footer>
	<p class="disclaimer">
		No guarantees are provided on the accuracy, timeliness, reliability, and appropriateness, or completeness of
		any services or data. They are provided "as is" and "as available" with no warranties or guarantees.
	</p>

	<p><a href="https://nadh.in">Kailash Nadh</a> &copy; 2022</p>
</footer>

<script>
	document.querySelectorAll('code').forEach(el => {
	el.style.cursor = 'pointer';
	el.onclick = () => navigator.clipboard.writeText(el.innerText)
		.then(() => {
		el.style.backgroundColor = '#ffbe2e';
		setTimeout(() => el.style.backgroundColor = '', 500);
		});
	});
</script>

</body>
</html>
